package models
{
    import com.pamakids.models.BaseVO;
    import com.pamakids.services.QNService;
    import com.pamakids.utils.CloneUtil;
    
    public class PaintVO extends BaseVO
    {
        public function PaintVO()
        {
            super();
        }
        
        public var author:UserVO //画作者，可以获取到用户昵称和id	
        public var cover:String //封面地址	634*477：显示于作品详情页
//        public var animeCover:String //动画封面地址	634*477：显示于作品详情页
//		441*332：显示于画廊列表大图
//		300*226：显示于用户个人中心
//		213*160：显示于画廊列表小图s
//		58*43：显示于消息列表
        public var data:String //绘图数据文件地址	
//        public var animeData:String //动画数据文件地址	
        
        public var audio:String //音频文件地址	
        
        public var views:Number //浏览数	
        public var plays:Number //播放数	
        public var comments:Number //评论数	
        public var enumLikes:Number //固定评论数	
        public var favorites:Number //收藏数	
        public var agrees:Number=0 //赞数	
        public var shares:Number //分享数	
        public var name:String //画作名	
        public var diamond:Boolean //是否为钻	
        
        public var beLiked:Boolean //是否赞过
        public var beVoted:Boolean //是否投票过
        public var disableEnum :Boolean //能否固定评论
        public var type:int=1 //1:普通 2 合集 3 :故事 4: 比赛
        public var subType:int;//1:社区，2：比赛，3：动画
        public var typeId:String
        
        public var local:Boolean;
        public var path:String;
        public var title:String;
        
        public var vote:Number;
        
        public var sortUpdated:String;
        
        public var mpublic:int;
        
//		public var big:Boolean;
        
        public var theme:String;
        
        public var commentsCount:int;
        
//		public function get match():Boolean
//		{
//			return _match||mpublic>=2;
//		}
        
        public var votable:Boolean;
        
        public function get coverUrl():String
        {
            return VO.FILESERVER_HOST + cover;
        }
        
        public function getSmallCover(w:Number,h:Number):String
        {
            return QNService.getQNThumbnail(cover,w,h);
        }
        
        public function getCoverUrlBySize(w:Number, h:Number):String
        {
            return QNService.getQNThumbnail(cover, w, h, 1);
        }
        public function get dataUrl():String
        {
            return VO.FILESERVER_HOST + data;
        }
        
//        public function get animeDataUrl():String
//        {
//            return VO.FILESERVER_HOST + animeData;
//        }
        
        public function get audioUrl():String  
        {
            return VO.FILESERVER_HOST + audio;
        }
        
        public function get audioUrlMp3():String
        {
            return VO.FILESERVER_HOST + audio + VO.AUDIO_MP3;
        }
        
        public var match:Object;
        
        public static function convertPV(o:Object):PaintVO
        {
            if(!o)
                return null;
            o.author=CloneUtil.convertObject(o.author, UserVO);
            var pv:PaintVO=CloneUtil.convertObject(o, PaintVO);
            pv.mpublic=o['public']
            //				pv.cover=pv.cover.replace("http://db.pamakids.com/", "");
//			pv.data=pv.cover.replace("thumb.jpg", "config.json");
            //				pv.author=CloneUtil.convertObject(o.author, UserVO);
            //				trace(pv._id)
            if(o.id&&!pv._id)
                pv._id=o.id;
            if(pv.typeId&&pv.type==1)
                pv._id=pv.typeId;
            if(o.albumId)
                pv._id=o.albumId;
            return pv;
        }
        
        public function getAudio():String
        {
            return cover.replace(VO.THUMB_NAME, VO.AUDIO_NAME_AMR);
        }
    }
}


